#include <stdio.h>
#include <stdlib.h>
//#define WDEBUG //在Windows平台运行时取消注释，用于在程序运行结束后使窗口不要消失

#ifdef WDEBUG
#include <windows.h>
#endif

struct member
{
    int id;
    struct member *next;
};

void freememory(struct member *rubbish, int m)
{
    struct member *pointer;
    while (m--)
    {
        pointer = rubbish;
        rubbish = rubbish->next;
        free(pointer);
    }
}

int main()
{
    int m, n, m2, v;
    int i, first;
    struct member *master;
    struct member *nextstu;
    struct member *laststu;
    struct member *oldstu;
    master = (struct member *)malloc(sizeof(struct member));
    master->next = master;
    master->id = 1;
    laststu = master;

    //k series
    struct member *master2;
    struct member *nextstu2;
    struct member *laststu2;
    struct member *oldstu2;
    master2 = (struct member *)malloc(sizeof(struct member));
    master2->next = master2;
    laststu2 = master2;

    scanf("%d", &m);
    m2 = m;
    for (i = 2; i <= m; i++)
    {
        nextstu = (struct member *)malloc(sizeof(struct member));
        nextstu->id = i;
        laststu->next = nextstu;
        nextstu->next = master;
        if (i != m)
        {
            laststu = laststu->next;
        }
    }
    first = 1;
    while (scanf("%d", &n) == 1)
    {
        if (!first)
        {
            nextstu2 = master2;
            freememory(master2, m);
            master2 = (struct member *)malloc(sizeof(struct member));
            master2->next = master2;
            laststu2 = master2;
        }
        oldstu = laststu; // oldstu laststu master oldstu laststu master oldstu laststu master
        v = 1;
        while (m != 0)
        {
            if (m != 1)
            {
                for (i = 0; i < n; i++)
                {
                    laststu = laststu->next;
                    master = master->next;
                    if (i != n - 1)
                    {
                        oldstu = oldstu->next;
                    }
                }
                if (v == 1)
                {
                    master2->id = laststu->next->id;
                    v = 0;
                }
                else
                {
                    nextstu2 = (struct member *)malloc(sizeof(struct member));
                    nextstu2->id = laststu->next->id;
                    laststu2->next = nextstu2;
                    nextstu2->next = master2;
                    laststu2 = laststu2->next;
                    free(laststu->next);
                }

                //printf("%d ", laststu->next->id);

                laststu->next = master;
                laststu = oldstu;
            }
            else
            {

                nextstu2 = (struct member *)malloc(sizeof(struct member));
                nextstu2->id = master->id;
                laststu2->next = nextstu2;
                nextstu2->next = master2;
                free(master);

                //printf("%d ", master->id);
            }
            m -= 1;
        }
        m = m2;
        master = (struct member *)malloc(sizeof(struct member));
        master->next = master;
        master->id = master2->id;
        laststu = master;
        nextstu2 = master2;
        for (i = 2; i <= m; i++)
        {
            nextstu2 = nextstu2->next;
            nextstu = (struct member *)malloc(sizeof(struct member));
            nextstu->id = nextstu2->id;
            laststu->next = nextstu;
            nextstu->next = master;
            if (i != m)
            {
                laststu = laststu->next;
            }
        }
        nextstu2 = master2;
        first = 0;
    }
    for (i = 0; i < m2; i++)
    {
        printf("%4d", nextstu2->id);
        nextstu2 = nextstu2->next;
    }
#ifdef WDEBUG
    printf("\n");
    system("pause");
#endif
    return 0;
}